<template>
    <el-form ref="form" :model="setUp.form" label-width="110px">
            <div class="item-title">基础设置</div>
            <el-form-item style="margin-top: 0px;">
              <template slot="label">
                <div style="font-weight: normal;font-size: 17px">铃声音量:</div>
              </template>
              <el-slider style ="width: 650px" v-model="setUp.form.ringVolume" :max="15" show-stops></el-slider>
            </el-form-item>
            <el-form-item style="margin-top: 0px;">
              <template slot="label">
                <div style="font-weight: normal;font-size: 17px">报警音量:</div>
              </template>
              <el-slider style ="width: 650px" v-model="setUp.form.policeVolume" :max="50"></el-slider>
            </el-form-item>
            <el-form-item style="margin-top: 0px;">
              <template slot="label">
                <div style="font-weight: normal;font-size: 17px">屏幕亮度:</div>
              </template>
              <el-slider style ="width: 650px" v-model="setUp.form.screenBringthess" :max="10"></el-slider>
            </el-form-item>
            <div class="item-title">报警设置</div>
            <el-form-item style="margin-top: 0px;">
              <template slot="label">
                <div style="font-weight: normal;font-size: 17px">报警灯开关:</div>
              </template>
              <el-switch
                v-model="setUp.form.policeLed"
                :active-value="1"
                :inactive-value="0"
                active-color="#13ce66"
                inactive-color="#ff4949"
                active-text="是"
                inactive-text="否">
              </el-switch>
            </el-form-item>
            <el-form-item style="margin-top: 0px;">
              <template slot="label">
                <div style="font-weight: normal;font-size: 17px">通知模式:</div>
              </template>
              <el-radio-group v-model="setUp.form.deviceNotice">
                <el-radio
                  v-for="dict in noticeType"
                  :key="dict.dictValue"
                  :label="dict.dictValue"
                >{{dict.dictLabel}}</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item v-if="setUp.form.deviceAudio!=null" style="margin-top: 0px;">
              <template slot="label">
                <div style="font-weight: normal;font-size: 17px">当前音频:</div>
              </template>
              <audio controls>
                <source :src="Url(setUp.form.deviceAudio)">
              </audio>
            </el-form-item>
            <el-form-item style="margin-top: 0px;">
              <template slot="label">
                <div style="font-weight: normal;font-size: 17px">音频上传:</div>
              </template>
              <file-upload :fileType="['mp3','wav']" :fileSize="3" v-model="setUp.form.deviceAudio"/>
            </el-form-item>
            <el-form-item style="margin-top: 0px;">
              <template slot="label">
                <div style="font-weight: normal;font-size: 17px">备注:</div>
              </template>
              <div style="font-size: 17px">模式一:检测到敏感词后先闪灯提示，服务器确认后语音播报并发送通知</div>
              <div style="font-size: 17px">模式二:检测到敏感词不做闪光和语音提示，服务器确认后会发送通知</div>
            </el-form-item>
          </el-form>
</template>
<script>
import {  getDevice } from "@/api/patrol/device";
import {getDicts} from "@/api/system/dict/data";

export default {
 data() {
    return {
      //设置对象
      setUp:{
        form:{},
        open:false
      },
      noticeType:[],
    };
  },
  props:{
    deviceId:{
        type: Number,
        default:null,
    }
  },
  watch:{
    deviceId(newValue){
        this.deviceId = newValue
        this.getDevice()
    }
  },
  methods:{
    getDevice(){
        console.log(1111111);
        getDevice(this.deviceId).then(response => {
            this.setUp.form = response.data;
        });
      getDicts("notice_type").then(res=>{
        console.log(res)
            this.noticeType = res.data
      })
    },
  }
}
</script>
